package com.tbit.uqbike.object.pojo;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author MyWin E-mail:335918956@qq.com
 * @version 1.0
 * @createTime 2019-12-19 10:42
 */
public class UserStatInfo {
    public static final String PRO_TOTAL = "total";
    public static final String PRO_NAME_AUTH = "nameAuth";
    public static final String PRO_DEPOSIT = "deposit";
    public static final String PRO_DEP_VIP = "depositVip";
    public static final String PRO_BLACK_USER = "blackUser";
    //用户id
    private Integer userId;
    //品牌id
    private Integer accountId;
    // 1 押金用户
    private Integer depositState;
    // 实名认证 1 代表认证
    private Integer nameAuth;
    // 免押会员过期日期
    private Date depositDate;
    // 黑名单id
    private Integer blackUserId;

    public static Map<String, Integer> initMap() {
        Map<String, Integer> map = new HashMap<>();
        map.put(PRO_NAME_AUTH, 0);
        map.put(PRO_DEPOSIT, 0);
        map.put(PRO_DEP_VIP, 0);
        map.put(PRO_BLACK_USER, 0);
        return map;
    }

    public static Map<String, Integer> statItem(Map<String, Integer> map, UserStatInfo item) {
        if (item.nameAuth != null && item.nameAuth == 1) {
            incMapKey(map, PRO_NAME_AUTH);//实名认证
        }
        if (item.depositState != null && item.depositState == 1) {
            incMapKey(map, PRO_DEPOSIT);//提交押金
        }
        if (item.blackUserId != null) {
            incMapKey(map, PRO_BLACK_USER);//黑名单用户
        }
        if (null != item.depositDate && (item.depositDate.getTime() + 24 * 3600000) >= System.currentTimeMillis()) {//时间包括当天
            incMapKey(map, PRO_DEP_VIP);//免押用户
        }

        return map;
    }

    private static void incMapKey(Map<String, Integer> map, String key) {
        map.put(key, map.get(key) + 1);
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Integer getAccountId() {
        return accountId;
    }

    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    public Integer getDepositState() {
        return depositState;
    }

    public void setDepositState(Integer depositState) {
        this.depositState = depositState;
    }

    public Integer getNameAuth() {
        return nameAuth;
    }

    public void setNameAuth(Integer nameAuth) {
        this.nameAuth = nameAuth;
    }

    public Date getDepositDate() {
        return depositDate;
    }

    public void setDepositDate(Date depositDate) {
        this.depositDate = depositDate;
    }

    public Integer getBlackUserId() {
        return blackUserId;
    }

    public void setBlackUserId(Integer blackUserId) {
        this.blackUserId = blackUserId;
    }

    @Override
    public String toString() {
        return "UserStatInfo{" +
                "userId=" + userId +
                ", accountId=" + accountId +
                ", depositState=" + depositState +
                ", nameAuth=" + nameAuth +
                ", depositDate=" + depositDate +
                ", blackUserId=" + blackUserId +
                '}';
    }
}
